#!usr/bin/env python  
# -*- coding:utf-8 -*-
""" 
@author:robot
@file: max_area.py 
@version:
@time: 2023/12/29 
"""
container = [1, 8, 6, 2, 5, 4, 8, 3, 7]
result = 49


def max_area(height):
    res = 0
    # 初始化left、right的值
    left = 0
    right = len(height) - 1
    while left < right:
        # res等于之前res与当前左右指定的挡板最低的长度，与x轴相乘
        res = max(
            res,
            min(
                height[left],
                height[right]
            ) * (right - left)
        )
        # 如果左挡板 小于 右挡板，left+=1
        if height[left] < height[right]:
            left += 1
        # 如果右挡板 大于或等于左挡板，right-=1
        else:
            right -= 1
    return res


if __name__ == '__main__':
    print(max_area(container))
